home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group02b.txt / 000093_icon-group-sender_Mon Oct 28 07:59:56 2002.msg < prev    next >
Internet Message Format  |  2003-01-02  |  2KB

  1. Return-Path: <icon-group-sender>
  2. Received: (from root@localhost)
  3.     by baskerville.CS.Arizona.EDU (8.11.1/8.11.1) id g9SExrA05395
  4.     for icon-group-addresses; Mon, 28 Oct 2002 07:59:53 -0700 (MST)
  5. Message-Id: <200210281459.g9SExrA05395@baskerville.CS.Arizona.EDU>
  6. From: "Andrew Hamm" <ahamm@mail.com>
  7. X-Newsgroups: comp.lang.icon
  8. Subject: Re: Icon broken?
  9. Date: Mon, 28 Oct 2002 10:46:50 +1100
  10. X-Priority: 3
  11. X-MSMail-Priority: Normal
  12. X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
  13. X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
  14. To: icon-group@cs.arizona.edu
  15. Errors-To: icon-group-errors@cs.arizona.edu
  16. Status: RO
  17.  
  18. adeukcin wrote:
  19. > I am trying to write a simple Regular Expression...
  20. > s := "Ic(cond)best"
  21. > re := RePat("( \(cond\) )")
  22. >
  23. > i := 0
  24. > j := 0
  25. >
  26. > i := ReFind(re,s)
  27. > j := ReMatch(re,s,i)
  28. >
  29. > s[i:j] := "on is the"
  30. > write(s[i:j])
  31. >
  32. > From what I understand...
  33. > This should output something like...
  34. > "Icon is the best"
  35. > instead it gives me somthing like...
  36. > "Ic(on is the)best"
  37. >
  38. > the \( does not seem to remove the special meaning from (
  39. >
  40.  
  41. RePat - hmm - I haven't seen them before. However....
  42.  
  43. your problem is understanding the need to use \ in strings. If you want a \
  44. to be in a string, you need to back-slash it. The compiler reads the source
  45. code and interprets it first.
  46.  
  47. re := RePat("( \\(cond\\) )")
  48.  
  49. now, the string stored internally in the object code and executed by the
  50. runtime will contain the \ that you desire. Try writing the string to see
  51. the difference with and without the correct number of \
  52.  
  53.  
  54.